package com.zhao.savepassword;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/**
 * Created by zhao on 16-2-4.
 * 登陆
 *
 */
public class LogInFragment extends Fragment {
    private View mView;
    private String mPassword;
    private Button mBt_logIn;
    private EditText mEt_password;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        init();
        return mView;
    }
    private void init(){
        mView = View.inflate(getActivity(), R.layout.fragment_log_in, null);
        mPassword=getArguments().getString(MainActivity.KEY_PASSWORD,null);
        mBt_logIn =(Button) mView.findViewById(R.id.bt_log_in);
        mEt_password = (EditText)mView.findViewById(R.id.et_user_password);
        mBt_logIn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String password = mEt_password.getText().toString();
                if (!password.equals(mPassword)){
                    Toast.makeText(getContext(),"密码错误!",Toast.LENGTH_SHORT).show();
                    return;
                }
                Toast.makeText(getContext(),"登陆成功!",Toast.LENGTH_SHORT).show();
            }
        });
    }
}
